<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>机构首页</title>
    <meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<link rel="stylesheet" href="resources/bootstrap/css/bootstrap.min.css">
	<script src="resources/common/jquery/jquery-3.2.1.min.js"></script>
	<script src="resources/bootstrap/js/bootstrap.min.js"></script>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  <script type="text/javascript">
 	$(document).ready(function(){ 
 		//设置省市县
 		$.ajax({
        		url:'agency/allProvince.do',
        		type:'post',
        		async:true,//异步执行
        		timeout:5000,//超时时间5s
        		contentType:'application/json;charset=utf-8',//参数类型
        		success:function(data){//成功
	        			if(data == null){
	        				
	        			}else{
	        				var str = null;
	        				var d = null;
	        				var p = $("#province");
	        				var len = data.length;
	        				for(i=0;i<len;i++){
	        					d = data[i];
	        					str += "<option value='" + d.id + "'>" + data[i].name + "</option>";  
	        				}
	        				$("#province").append(str);
	        			}
		        	}
        	});
 		
 		
 		
 		
 		$("#province").change(function(){  //级联
 			var sel = $("#province").val();
            $.ajax({
        		url:'agency/allCity.do',
        		type:'post',
        		async:true,//异步执行
        		timeout:5000,//超时时间5s
        		data:JSON.stringify({"provinceId":sel}),//参数
        		contentType:'application/json;charset=utf-8',//参数类型
        		success:function(data){//成功
        				if(data == null){
	        				
	        			}else{
	        				var str = null;
	        				var d = null;
	        				var p = $("#city");
	        				var len = data.length;
	        				for(i=0;i<len;i++){
	        					d = data[i];
	        					str += "<option value='" + d.id + "'>" + data[i].name + "</option>";  
	        				}
	        				p.empty();
	        				$("#coutry").empty();
	        				p.append("<option value='default'>----请选择-----</option>");
	        				p.append(str);
	        			}
		        	}
        	});
        	
        	$("#city").change(function(){  //级联
 			var sel = $("#city").val();
            $.ajax({
        		url:'agency/allCoutry.do',
        		type:'post',
        		async:true,//异步执行
        		timeout:5000,//超时时间5s
        		data:JSON.stringify({"cityId":sel}),//参数
        		contentType:'application/json;charset=utf-8',//参数类型
        		success:function(data){//成功
        				if(data == null){
	        				
	        			}else{
	        				var str = null;
	        				var d = null;
	        				var p = $("#coutry");
	        				var len = data.length;
	        				for(i=0;i<len;i++){
	        					d = data[i];
	        					str += "<option value='" + d.id + "'>" + data[i].name + "</option>";  
	        				}
	        				p.empty();
	        				p.append("<option value='default'>----请选择-----</option>");
	        				p.append(str);
	        			}
		        	}
        		});
        	});
        	
        	
        });
 	});
  </script>
<body>
<div class="col-md-6 col-md-offset-3">
	<form class="form-horizontal" role="form" action="agency/select.do" method="get">
		<div class="form-group">
		    <label for="identifier" class="col-md-2 control-label">编号</label>
		    <div class="col-md-4">
		      <input type="text" class="form-control" id="identifier" name="identifier" placeholder="机构编号">
		    </div>
		    <label for="name" class="col-md-2 control-label">名称</label>
		    <div class="col-md-4">
		      <input type="text" class="form-control" id="name" placeholder="机构名称">
		    </div>
		  </div>
		<div class="form-group">
		    <label for="addr" class="col-md-2 control-label">地区</label>
		    <div class="col-md-3">
		      <select id="province" class="form-control" >
		      <option value="default">----请选择-----</option>
		      </select>
		    </div>
		    <div class="col-md-3">
		      <select id="city" class="form-control" >
		      </select>
		    </div>
		    <div class="col-md-3">
		      <select id="coutry" class="form-control" >
		      </select>
		    </div>
		  </div>
		  <div class="form-group">
		  	<div class="col-md-3 col-md-offset-4">
		      <button type="submit" class="btn btn-default" id="select">查询</button>
		    </div>
		  </div>
	</form>
</div>
</body>
</html>
